-
Notifications
You must be signed in to change notification settings - Fork 5.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
【BUAA】【Infer Symbolic Shape No.152,153】Add max_pool2d_with_index and max_pool3d_with_index #67390
Conversation
你的PR提交成功,感谢你对开源项目的贡献! |
coverage_exit: 9 max_pool2d_with_index和 max_pool3d_with_index均无相应OpTest文件 |
const auto &x = x_shape[i + 2]; | ||
if (x.isa<int64_t>()) { | ||
kernel_size_[i] = static_cast<int64_t>(x.Get<std::int64_t>()); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里应该不需要特判x是否为int64,kernel_size_直接变成DimExpr参与符号计算即可
int64_t x = static_cast<int64_t>(x_dim.Get<std::int64_t>()); | ||
if (x < 0) { | ||
out_shape.push_back(x_shape[i + 2]); | ||
} else { | ||
PADDLE_ENFORCE_NE( | ||
strides[i], | ||
0, | ||
phi::errors::InvalidArgument( | ||
"The stride of MaxPool shall not be 0, but received %d.", | ||
strides[i])); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
直接使用符号计算,这里x<0是infer meta无法处理动态shape做的特判
bool MaxPool3dWithIndexOpInferSymbolicShape( | ||
pir::Operation *op, pir::InferSymbolicShapeContext *infer_context) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
两个函数有很多相同逻辑,建议抽象点共同操作
…pe/.ipynb_checkpoints directory
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
std::vector<int> strides = | ||
paddle::dialect::details::GetVectorAttr<int>(op, "strides"); | ||
std::vector<int> kernel_sizes_ = | ||
paddle::dialect::details::GetVectorAttr<int>(op, "kernel_sizes"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
kernel_size
typo修复PR:#67548 |
PR Category
CINN
PR Types
Others
Description
添加 max_pool2d_with_index和 max_pool3d_with_index 算子符号推导接口实现。